#!/usr/bin/python
# -*- coding: iso-8859-15 -*-

from xml.etree.ElementTree import parse

class Mapping:
	def __init__(self,mapfile):
		dom = parse(mapfile)
		root = dom.getroot()
		self.dico = {}
		i = 0
		
		for keys in root.findall("key"):
			self.dico[keys.text] = root.findall("value")[i].text
			i = i+1
			
	def getValue(self,key):
		if(self.exist(key)):
			return self.dico[key]
		else:
			return 0
	
	def getKey(self, value):
		if(value in self.dico.values()):
			for key in self.dico.keys():
				if self.dico[key]== value :
					return key
		else :
			return 0
		
	def exist(self,key):
		return self.dico.has_key(key)


if __name__=="__main__":
	test = Mapping("iwconfig.mapping");
	print test.getValue("Power Management");
